{{!
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License.  You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
}}

<div class="accordion-heading" {{action "onToggleBlock" category target="view"}}>
  <i {{bindAttr class=":pull-left :accordion-toggle view.category.isCollapsed:icon-caret-right:icon-caret-down"}}></i>
  <a class="accordion-toggle category-header">
    <span class="category-name">{{view.category.displayName}}</span>
    {{#if view.category.errorCount}}
      <span class="badge badge-important">{{view.category.errorCount}}</span>
    {{/if}}
  </a>
</div>

<div class="accordion-body collapse in" {{bindAttr style="view.isCategoryBodyVisible"}}>
  <div class="accordion-inner service-config-section">
    <form class="form-horizontal" autocomplete="off">
      {{#each view.categoryConfigs}}
        {{#unless widget}} {{! configs with widgets should be shown only on the EnhancedConfigs tabs }}
          <div {{bindAttr class=":entry-row isHiddenByFilter:hide isOverridden:overridden-property hasCompareDiffs:overridden-property"}}>
            {{#if showLabel}}
              {{#unless rightSideLabel}}
                <span {{bindAttr class="errorMessage:error: :control-group :control-label-span"}}>
                  <label class="control-label">
                    {{formatWordBreak displayName}}
                    {{#if isSecureConfig}}
                      <a href="javascript:void(null);"><i class="icon-lock" rel="tooltip" data-toggle="tooltip"
                                                          title="security knob"></i></a>
                    {{/if}}
                  </label>
                </span>
              {{else}}
                <span class="control-group control-label-span"> </span>
              {{/unless}}
            {{/if}}
            <div {{bindAttr class="showLabel:controls"}}>
              {{! Here serviceConfigBinding should ideally be serviceConfigPropertyBinding }}
              {{#if this.isOriginalSCP}}
                <div {{bindAttr class="errorMessage:error: warnMessage:warning: :control-group"}}>
                  {{view viewClass serviceConfigBinding="this" categoryConfigsAllBinding="view.categoryConfigsAll" }}
                  {{#if rightSideLabel}}
                    <span {{bindAttr class="isEditable::muted"}}>{{formatWordBreak displayName}}</span>
                  {{/if}}
                  {{#if hintMessage}}
                    <a class="icon-question-sign icon-blue" href="#" data-toggle="tooltip" {{bindAttr data-original-title="hintMessage"}}></a>
                  {{/if}}
                  {{#if this.isComparison}}
                    {{#if controller.selectedConfigGroup.isDefault}}
                      <span
                          class="label label-info">{{t dashboard.configHistory.table.version.prefix}}{{controller.selectedVersion}}</span>
                      {{#if controller.isCurrentSelected}}
                        <span class="label label-success">{{t common.current}}</span>
                      {{/if}}
                    {{else}}
                      <span class="label label-info">{{t common.default}}
                        &nbsp;{{t services.service.config.configHistory.configGroup}}</span>
                    {{/if}}
                  {{/if}}
                  {{view App.ControlsView serviceConfigPropertyBinding="this"}}
                  <span class="help-inline">{{errorMessage}}</span>
                  <span class="help-inline">{{warnMessage}}</span>
                </div>
              {{/if}}
              {{#if this.isComparison}}
                {{#unless this.isOriginalSCP}}
                  {{view viewClass serviceConfigBinding="this" categoryConfigsAllBinding="view.categoryConfigsAll" }}
                  {{#if controller.selectedConfigGroup.isDefault}}
                    <span
                      class="label label-info config-controls">{{t dashboard.configHistory.table.version.prefix}}{{controller.selectedVersion}}</span>
                    {{#if controller.isCurrentSelected}}
                      <span class="label label-success config-controls">{{t common.current}}</span>
                    {{/if}}
                  {{else}}
                    <span class="label label-info config-controls">{{t common.default}}
                      &nbsp;{{t services.service.config.configHistory.configGroup}}</span>
                  {{/if}}
                {{/unless}}
                {{view App.ServiceConfigView.SCPComparisonRowsView serviceConfigPropertyBinding="this"}}
              {{else}}
                {{#if this.isOverridden}}
                  {{view App.ServiceConfigView.SCPOverriddenRowsView
                  serviceConfigPropertyBinding="this"
                  isDefaultGroupSelectedBinding="controller.selectedConfigGroup.isDefault"
                  }}
                {{/if}}
              {{/if}}
            </div>
          </div>
          {{#if this.additionalView}}
            {{view additionalView}}
          {{/if}}
        {{/unless}}
      {{/each}}

      {{! For Advanced, Advanced Core Site, Advanced HDFS Site sections, show the 'Add Property' link.}}
      {{#isAuthorized "SERVICE.MODIFY_CONFIGS"}}
        {{#if view.canEdit}}
          {{#if view.category.customCanAddProperty}}
            <div>
              <a href="#" {{action "showAddPropertyWindow" this target="view" }} >{{t installer.step7.config.addProperty}}
                ...</a>
            </div>
          {{/if}}
        {{/if}}
      {{/isAuthorized}}
    </form>
  </div>
</div>
